from fastapi import APIRouter, Query,UploadFile
from tortoise.expressions import Q
from app.controllers.orders.water import orders_water_controller
from app.schemas.base import Success, SuccessExtra,Fail
orders_water_router = APIRouter()
model_name = "微信支付流水"


@orders_water_router.get("/list", summary=f"查看{model_name}列表")
async def do_water_list(
        page: int = Query(1, description="页码"),
        page_size: int = Query(10, description="每页数量"),
        order_id: int = Query(0, description="订单id"),
):
    q = Q()
    if order_id:
        q &= Q(order_id=order_id)
    total, data = await orders_water_controller.do_list(page=page, page_size=page_size, search=q)
    for item in data:
        item['amount'] = item['amount']/100
    return SuccessExtra(data=data, total=total, page=page, page_size=page_size)
